﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL.Entity;
using DAL.Persistencia;

namespace NewTierra.Pages.Servicos
{
    public partial class InfoServico : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BuscaInfos();
                CarregarListFotos(sender,e);
            }
        }

        protected void BuscaInfos()
        {
            try
            {
                ServicoDAL s = new ServicoDAL();

                S_Servicos ss = s.ObterPorId(Convert.ToInt32(Session["IdServico"]));

                lblNomeServico.Text = ss.Servicos_Nome;
                lblCidade.Text = ss.Cidade.CID_nome;
                lblPais.Text = ss.Pai.PAIS_nome;
                lblInfoLong.Text = ss.Servicos_descr;
                lblInfoShort.Text = ss.Servicos_descrCurt;

                FotoServicoDAL f = new FotoServicoDAL();
                FotoPrincipal.ImageUrl = "~/Galeria/Servicos/" + ss.Servicos_Id + "/" + f.ObterImgPrincipal(ss.Servicos_Id).Serv_img_nome;

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }

        protected void CarregarListFotos(object sender, EventArgs e)
        {
            CarregarFotos(sender, e);
        }

        protected void CarregarFotos(object sender, EventArgs e)
        {
            try
            {
                FotoServicoDAL f = new FotoServicoDAL();

                DataListFotosInfo.DataSource = f.ListarTodos(Convert.ToInt32(Session["IdServico"]));
                DataListFotosInfo.DataBind(); //Desenhar
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }

    }
}